package com.yunji.ylexpiration.service.impl;

import com.yunji.ylexpiration.entity.FurnVarietys;
import com.yunji.ylexpiration.entity.FurnVarietysExample;
import com.yunji.ylexpiration.mapper.FurnVarietysMapper;
import com.yunji.ylexpiration.service.FurnVarietysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FurnVarietysServiceImpl implements FurnVarietysService {
    @Autowired
    private FurnVarietysMapper furnVarietysMapper;

    @Override
    public List<FurnVarietys> selectByscoreId(Integer scoreId) {
        FurnVarietysExample example = new FurnVarietysExample();
        FurnVarietysExample.Criteria criteria = example.createCriteria();
        criteria.andSoreidEqualTo(scoreId);
        List<FurnVarietys> furnVarietys = furnVarietysMapper.selectByExample(example);
        if(furnVarietys==null||furnVarietys.size()==0){
            return null;
        }
        return furnVarietys;
    }

    @Override
    public Double selectByimg(String varityname) {
        FurnVarietysExample example = new FurnVarietysExample();
        FurnVarietysExample.Criteria criteria = example.createCriteria();
        criteria.andVaritynameEqualTo(varityname);
        List<FurnVarietys> furnVarietys = furnVarietysMapper.selectByExample(example);
        if(furnVarietys==null||furnVarietys.size()==0){
            return null;
        }
        FurnVarietys furnVarietys1 = furnVarietys.get(0);
        Double price = furnVarietys1.getPrice();
        return price;
    }
}
